home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-01-16 | 3.3 KB | 69 lines | [TEXT/MPS ] |
- Macintosh
- Sample Code Notes
- _____________________________________________________________________________
- Developer Technical Support
- #20: Transformer
-
- Written by: Keith Rollin
-
- Versions: 1.00 February 1990
-
- Components: MTransformer.p February 1, 1990
- Transformer.c February 1, 1990
- Transformer.r February 1, 1990
- UTransformer.p February 1, 1990
- UTransformer.inc1.p February 1, 1990
- Transformer.MAMake February 1, 1990
-
- Additional Documentatation: The BitMap Transmogrifier (MacWrite)
- _____________________________________________________________________________
-
- Transformer is a sample program that demonstrates:
-
- - bitmap transformations
- - mixing MacApp with C subroutines
- - mixing 68881 and non-68881 code together
- - calling of MacApp routines from C
- - using CursorCtl routines
- - turning on and off the MacApp BusyCursor mechanism
-
- It uses a MacApp shell to open file, open windows, and handle menus, but
- uses a core routine written in vanilla C to perform the actual transformation.
- The transformation consists of translating, scaling, and rotating. The comments
- in the source code are sparse, if existant at all, so gleaning how the
- transformation routine works is very difficult. To explain what is going on,
- a sister document, "The BitMap Transmogrifier," has been included. It explains
- all of the necessary math, and shows how the formulas were derived. There are
- also lots of pictures.
-
- Adding C routines to a MacApp program used to be a pain, but no longer.
- Previously, weird gyrations had to be performed in order to get things to
- link correctly and without lots of warnings or errors. Now with MacApp 2.0ß9
- and later, support has been explicitly provided in MABuild for mixing in C.
-
- For best performance, the C routine is compiled with the -mc68881 option (this
- is set in the MAMake file). A problem arises with this, as an extended value
- is passed from the non-FPU Pascal code to the FPU C code. Since the size of
- extended values changes depending on the setting of the 68881 options, the
- parameters have to be converted as per page 347 of the MPW 3.0 Pascal manual.
-
- In our C routine, we make use of some of the MacApp utilities. This is
- done by making a small set of external declarations that match the Pascal
- interfaces for the routines we are interested in. This is done for FailNIL,
- FailOSErr, and BusyActivate.
-
- BusyActivate is a routine that controls the BusyCursor mechanism of MacApp.
- This mechanism gives MacApp programs a built-in watch cursor that kicks in
- whenever the application is involved in a lengthy process. During our
- transformation routine we want this turned off, as we supply our own busy
- indicator with the CursorCtl library routines.
-
- The CursorCtl library routines allow one to implement the spinning beachball
- cursor. We set this up when we initialize our application with a call to
- InitCursorCtl. This reads in our 'acur' and 'CURS' resources and initializes
- them in whatever way it deems necessary. When we need to show the spinning
- cursor, we just start calling SpinCursor() with some rotation value. This
- rotation value is added to an internal counter. When this counter reaches 32,
- the next cursor specified in the 'acur' resource is shown. More information
- on this is included in the interface files for CursorCtl.
-